{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>审核活动</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" name="add_article" id="add_article" enctype="multipart/form-data">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">标题：</label>
                            <div class="input-group col-sm-4">
                                <input id="title"  type="text" name="information_title" class="form-control title">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">资讯类型：</label>
                            <div class="input-group col-sm-4">
                                <select class="form-control m-b chosen-select" name="information_type_id" id="type_name">
                                    {volist name="list" id="vo"}
                                    <option value="{$vo.information_type_id}" >{$vo.information_type_name}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">图片：</label>
                            <div class="input-group col-sm-5">
                                <input type="hidden" id="data_photo" name="images" value="">
                                <div id="imgPicker" style="float:left">选择图片</div>
                                <img id="img_data" height="100px" style="float:left;margin-left: 50px;margin-top: -10px;cursor:pointer;" src="/static/admin/images/no_img.jpg" onclick='imgDisplay(this)'/>
                                <div id="fileList" class="uploader-list" style="float:right"></div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">资讯来源：</label>
                            <div class="input-group col-sm-4">
                                <input type="text"  name="mechanism_for" class="form-control mechanism_for">
                            </div>
                        </div>

                        <div class="form-group" id="content">
                            <label class="col-sm-3 control-label" for="myEditor">资讯介绍：</label>
                            <div class="input-group col-sm-9 " >
                                <textarea name="information_introduce" class="content information_introduce" style="width:660px;height:190px"></textarea>
                            </div>
                        </div>
                        <div class="form-group" id="MyContent">
                            <label class="col-sm-3 control-label cyanse" for="myEditor">资讯详情：</label>
                            <div class="input-group col-sm-9">
                                <textarea  name="information_content" class="information_content" style="width:90%" id="myEditor"></textarea>
                                <a id="myEditors" style="color:#A94543"></a>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary btsave"  type="button"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
    wk.upload("{:url('Upload/upload')}",2);

    //百度富文本编辑器
    var editor = UE.getEditor('myEditor', {
        initialFrameHeight:450,
        autoHeight: false,
        autoHeightEnabled:false,
        autoFloatEnabled:false
    });
</script>
<script>
    $(".btsave").on('click',function () {
        $('.btn').attr('disabled',true);
        var information_introduce = $(".information_introduce").val();//活动介绍
        var information_content = UE.getEditor('myEditor').getContentTxt();//资讯详情
        var title = $(".title").val();//活动标题
        var mechanism_for = $(".mechanism_for").val();//来源
        if(title==''){
            layer.msg("标题不能为空", {icon: 1, time: 1500, shade: 0.1}, function (index) {
            });
            $('.btn').removeAttr('disabled');

            return false;
        }
        if(mechanism_for==''){
            layer.msg("来源不能为空", {icon: 1, time: 1500, shade: 0.1}, function (index) {
            });
            $('.btn').removeAttr('disabled');

            return false;
        }
        if(information_introduce==''){
            layer.msg("资讯介绍不能为空", {icon: 1, time: 1500, shade: 0.1}, function (index) {
            });
            $('.btn').removeAttr('disabled');

            return false;
        }
        if(information_content==''){
            layer.msg("资讯详情不能为空", {icon: 1, time: 1500, shade: 0.1}, function (index) {
            });
            $('.btn').removeAttr('disabled');

            return false;
        }
        $.ajax({
            url: "{:url('add')}",
            type: "post",
            dataType:'json',
            data: $("#add_article").serialize(),
            success: function (data) {
                if (data.code == 200) {
                    wk.success(data.msg,1,"{:url('information/index')}");
                } else if(data.code == 100){
                    $('.btn').removeAttr('disabled');
                    wk.error(data.msg,2,'');
                    return false;
                }
            }
        });
    })
</script>
</body>
</html>